import request from '@/utils/request';

export const fetchCodeImageApi = () => {
  return request({
    url: '/captchaImage',
    needToken: false,
  });
};

export const loginApi = (data) => {
  return request({
    url: '/login',
    needToken: false,
    method: 'POST',
    data,
  });
};

interface UserInfo {
  user: Record<string, any>;
  roles: string[];
  permissions: string[];
}

export function getInfoApi() {
  return request<UserInfo>({
    url: '/getInfo',
  });
}

export const fetchTokenUseUserId = (userId: string) => {
  return request({
    url: '/qwWeiXin/getTokenByQyWxUserId',
    params: {
      userId,
    },
    skipError: true,
  });
};
